package com.fy.merchant.controller;

import com.fy.common.api.CommonResult;
import com.fy.merchant.reqvo.SettledInputVo;
import com.fy.merchant.reqvo.SettledMerchantVo;
import com.fy.shop.api.DistributorService;
import com.fy.shop.dto.SettledInputDto;
import com.fy.user.api.DistributorSpotService;
import com.fy.user.dto.SettledMerchantDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "景区商户入驻")
@RestController
@RequestMapping("/show")
@RefreshScope
public class ScenicSpotController {

    @Autowired
    private DistributorService distributorService;

    @Autowired
    private DistributorSpotService distributorSpotService;

    @ApiOperation("入驻申请")
    @PostMapping(value = "enter")
    public CommonResult enter(@RequestBody SettledMerchantVo settledMerchantVo) {
        SettledMerchantDto settledMerchantDto = new SettledMerchantDto();
        BeanUtils.copyProperties(settledMerchantVo,settledMerchantDto);
        distributorSpotService.enter(settledMerchantDto);
        return CommonResult.success(null);
    }

    @ApiOperation("修改景区店铺信息")
    public CommonResult updateEnter(@RequestBody SettledInputVo settledInputVo){
        SettledInputDto settledInputDto = new SettledInputDto();
        BeanUtils.copyProperties(settledInputVo,settledInputDto);
        distributorService.updateEnter(settledInputDto);
        return CommonResult.success(null);
    }


}
